<?php
require_once dirname(__FILE__).'/public_func.php';
class admin extends publics{

	function admin(){
		$this->db_con();
	}
	//数据统计函数
	function info_count($data,$rules=""){
		$table_name = $data."_info";
		return $this->db_count($table_name,$rules);
	}
	//获取教师信息列表
	function GetTeacherList($pager='1'){
		if($pager!='' && $pager==1){
			$data = $this->db_select('teacher_info');
		}else{
			$data = $this->db_select('teacher_info','','*',$pager);
		}
		return $data;
	}
	//获取学生信息列表
	function GetStudentList($pager='1'){
		if($pager!='' && $pager==1){
			$data = $this->db_select('student_info');
		}else{
			$data = $this->db_select('student_info','','*',$pager);
		}
		return $data;
	}
	//获取身份证信息列表
	function GetCardList($pager='1'){
		if($pager!='' && $pager==1){
			$data = $this->db_select('card_info');
		}else{
			$data = $this->db_select('card_info','','*',$pager);
		}
		$n = count($data);
		$i = 0;
		while($i<$n){
			$data[$i]['sex'] = $this->GetSex($data[$i]['sex']);
			$i++;
		}
		return $data;
	}
	//获取选课信息列表
	function GetChoiceList($pager='1'){
		if($pager!='' && $pager==1){
			$data = $this->db_select('sign_info');
		}else{
			$data = $this->db_select('sign_info','','*',$pager);
		}
		$n = count($data);
		$i = 0;
		while($i<$n){
			$data[$i]['student'] = $this->GetSigleInfo("student_info",$data[$i]['s_id']);
			$data[$i]['course'] = $this->GetSigleInfo("course_info",$data[$i]['c_id']);
			$data[$i]['course']['c_time'] = $this->WeekTrans($data[$i]['course']['c_week']);
			$data[$i]['course']['weeks'] = $this->WeeksTrans($data[$i]['course']['c_weeks']);
			$t_id = $data[$i]['course']['t_id'];
			if($t_id!="0"){
				$name = $this->db_select('teacher_info','id = '.$t_id,'t_name');
				$data[$i]['course']['t_name'] = $name['0']['t_name'];
			}else{
				$data[$i]['course']['t_name'] = "————";
			}
			if($data[$i]['c_status']==0){
				$data[$i]['status'] = "未定";
			}else if($data[$i]['c_status']==1){
				$data[$i]['status'] = "确定";
			}
			$i++;
		}
		return $data;
	}
	//获取签到信息列表
	function GetSignList($pager='1'){
		if($pager!='' && $pager==1){
			$data = $this->db_select('sign_info','c_status = 1');
		}else{
			$data = $this->db_select('sign_info','c_status = 1','*',$pager);
		}
		$n = count($data);
		$i = 0;
		while($i<$n){
			$data[$i]['student'] = $this->GetSigleInfo("student_info",$data[$i]['s_id']);
			$data[$i]['course'] = $this->GetSigleInfo("course_info",$data[$i]['c_id']);
			$data[$i]['course']['c_time'] = $this->WeekTrans($data[$i]['course']['c_week']);
			$data[$i]['course']['weeks'] = $this->WeeksTrans($data[$i]['course']['c_weeks']);
			$t_id = $data[$i]['course']['t_id'];
			if($t_id!="0"){
				$name = $this->db_select('teacher_info','id = '.$t_id,'t_name');
				$data[$i]['course']['t_name'] = $name['0']['t_name'];
			}else{
				$data[$i]['course']['t_name'] = "————";
			}
			$i++;
		}
		return $data;
	}
	//获取时间信息列表
	function GetTimeList(){
		$data = $this->db_select('schedule','');
		$n = count($data);
		$i = 0;
		while($i<$n){
			$data[$i]['type'] = $this->GetSchedule($data[$i]['type']);
			$data[$i]['order'] = $this->GetTimeOrder($data[$i]['order']);
			$i++;
		}
		return $data;
	}
	//获取课程信息列表
	function GetCourseList($pager='1'){
		if($pager!='' && $pager==1){
			$data = $this->db_select('course_info');
		}else{
			$data = $this->db_select('course_info','','*',$pager);
		}
		$n = count($data);
		$i = 0;
		while($i<$n){
			$data[$i]['c_time'] = $this->WeekTrans($data[$i]['c_week']);
			$t_id = $data[$i]['t_id'];
			if($t_id!="0"){
				$name = $this->db_select('teacher_info','id = '.$t_id,'t_name');
				$data[$i]['t_name'] = $name['0']['t_name'];
			}else{
				$data[$i]['t_name'] = "————";
			}
			$data[$i]['weeks'] = $this->WeeksTrans($data[$i]['c_weeks']);
			$i++;
		}
		return $data;
	}
}
?>